/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Views.GestionRestaurant;

import Controller.Controller;
import Model.Restaurateur;
import java.awt.Component;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author ibrahim
 */
public class RestaurateurRenderer implements TableCellRenderer {
    private JComboBox combo;
    private DefaultComboBoxModel restComboModel;
    public RestaurateurRenderer(Controller controller){
        this.combo = new JComboBox();
        restComboModel = new DefaultComboBoxModel();
        for(Restaurateur rest:controller.getRestauraterurs()){
           restComboModel.addElement(rest.getFname()+" "+ rest.getLname()); 
        }
        combo.setModel(restComboModel);
    }
    

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
       
       combo.setSelectedItem(value);
       return combo;
        
    }
    
}
